package com.eber.demo.design.state.c;

import lombok.Getter;

@Getter
public class Context {
    // 定义出所有的电梯状态
    /*public final static OpeningState openingState = new OpeningState();
    public final static ClosingState closingState = new ClosingState();
    public final static RunningState runningState = new RunningState();
    public final static StoppingState stoppingState = new StoppingState();*/

    private LiftStateAbstract liftState;

    public Context() {
        this.liftState = new ClosingState();
        this.liftState.setContext(this);
    }

    public void setLiftState(LiftStateAbstract liftState) {
        this.liftState = liftState;
        this.liftState.setContext(this);
    }

    public void open() {
        this.getLiftState().open();
    }
    public void close() {
        this.getLiftState().close();
    }
    public void run() {
        this.getLiftState().run();
    }
    public void stop() {
        this.getLiftState().stop();
    }
}
